home *** CD-ROM | disk | FTP | other *** search
/ Clickx 96 / Clickx 96.iso / software / tools / tool / xbmc-10.1.exe / addons / webinterface.default / js / Core.js next >
Encoding:
JavaScript  |  2011-03-08  |  2.1 KB  |  69 lines

  1. /*
  2.  *      Copyright (C) 2005-2010 Team XBMC
  3.  *      http://www.xbmc.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with XBMC; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21.  
  22. /* Global Paths */
  23.  
  24. var JSON_RPC = '/jsonrpc';
  25. var DEFAULT_ALBUM_COVER = 'images/DefaultAlbumCover.png';
  26. var DEFAULT_VIDEO_COVER = 'images/DefaultVideo.png';
  27.  
  28. /* Prototypes */
  29.  
  30. String.prototype.startsWith = function(prefix) {
  31.     return this.indexOf(prefix) === 0;
  32. }
  33.  
  34. String.prototype.endsWith = function(suffix) {
  35.     return this.match(suffix + "$") == suffix;
  36. }
  37.  
  38. function durationToString(duration) {
  39.     if (!duration) {
  40.         return '00:00';
  41.     }
  42.     minutes = Math.floor(duration / 60);
  43.     hours = Math.floor(minutes / 60);
  44.     minutes = minutes % 60;
  45.     seconds = duration % 60;
  46.     var result = '';
  47.     if (hours) {
  48.         result += (hours < 10 ? '0' + hours : hours) + ':';
  49.     }
  50.     result += (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds);
  51.     return result;
  52. }
  53.  
  54. function applyDeviceFixes() {
  55.     document.addEventListener('touchmove', function(e){ e.preventDefault(); });
  56. }
  57.  
  58. var commsErrorTimeout;
  59.  
  60. function displayCommunicationError(m) {
  61.     clearTimeout(commsErrorTimeout);
  62.     var message = m||'Connection to server lost';
  63.     $('#commsErrorPanel').html(message).show();
  64.     commsErrorTimeout = setTimeout('hideCommunicationError()', 5000);
  65. }
  66.  
  67. function hideCommunicationError() {
  68.     $('#commsErrorPanel').hide();
  69. }